# tests.py
from django.test import TestCase
from django.contrib.auth import get_user_model


class AuthBackendTest(TestCase):
    def setUp(self):
        self.user = get_user_model().objects.create_user(
            username='周文忠',
            phone='15801890580',
            password='123456'
        )

    def test_phone_login(self):
        # 正确密码测试
        self.client.login(username='周文忠', password='123456')
        self.assertTrue(self.user.is_authenticated)

        # 错误密码测试
        # self.client.login(username='13812345678', password='WrongPwd')
        # self.assertFalse(self.user.is_authenticated)
